#ifndef CONCRETE_SUBJECT_H
#define CONCRETE_SUBJECT_H

#include"subject.h"
#include"observer.h"
#include<iostream>
#include<list>
using namespace  std;

class SubjectA:public ISubject{
public:
    SubjectA():m_fPrice(8.0){}
    void SetPrice(double price){
        m_fPrice=price;
    }
    double GetPrice(){
        return m_fPrice;
    }
    void Attach(IObserver *observer)override{
        m_list.insert(m_list.cend(),observer);
    }
    void Detach(IObserver *observer)override{
        m_list.remove(observer);
    }
    void Notify()override{  //遍历通知观察者
        for(auto observer:m_list)
            observer->Update(m_fPrice);
    }
private:
    list<IObserver*> m_list;
    double m_fPrice; //价格
};
#endif // CONCRETE_SUBJECT_H
